<!DOCTYPE html>
<html class="x-admin-sm">

<head>
	<meta charset="UTF-8">
	<title>电子学会比赛管理系统</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
	<link rel="stylesheet" href="./css/font.css">
	<link rel="stylesheet" href="./css/common.css">
	<link rel="stylesheet" href="./css/xadmin.css">
	<script type="text/javascript" src="./js/abkj/auth/api/adminzoneview.js"></script>
	<script type="text/javascript" src="./js/abkj/auth/api/account.js"></script>
	<script type="text/javascript" src="./js/abkj/match/api/grade.js"></script>
	<script type="text/javascript" src="./js/abkj/match/api/zone.js"></script>
	<script type="text/javascript" src="./js/abkj/match/api/schedule.js"></script>

	<script type="text/javascript" src="./js/abkj/match/api/tmatch.js"></script>
	<script type="text/javascript" src="./js/abkj/match/api/team.js"></script>
	<script type="text/javascript" src="./js/abkj/match/api/schedule.js"></script>
	<script type="text/javascript" src="./js/abkj/match/api/mathworklistview.js"></script>
		<script type="text/javascript" src="./js/abkj/auth/api/userinfoview.js"></script>
	<script type="text/javascript" src="./js/abkj/slAjax.js"></script>
	<script type="text/javascript" src="./js/abkj/fun_tool.js"></script>
	<script src="./lib/layui/layui.js" charset="utf-8"></script>
	<script type="text/javascript" src="./js/xadmin.js"></script>
</head>

<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">首页</a>
								<a><cite>比赛管理</cite></a>
                <a><cite>作品提交作品</cite></a>
            </span>
	<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
		<i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
	</a>
</div>
<div class="layui-fluid" id="content" v-cloak	>
	<div class="layui-row layui-col-space15">
		<div class="layui-col-md12">
			<div class="layui-card">
				<div class="layui-card-body ">
					<form class="layui-form layui-col-space5 flex" style="display: flex;" @submit.prevent>
						<!--<div class="layui-input-inline layui-show-xs-block">-->
						<!--<input class="layui-input" placeholder="开始日" name="start" id="start"></div>-->
						<!--<div class="layui-input-inline layui-show-xs-block">-->
						<!--<input class="layui-input" placeholder="截止日" name="end" id="end"></div>-->
						<div class="layui-input-inline layui-show-xs-block flex">
							<div class="mr5">赛项</div>
							<select name="selMatchId" id="saixiang" name="matchSelect" lay-filter="matchSelChange">
								<option value="">请选择</option>
								<option v-for="match in matchList" :value="match.theme">{{match.theme}}</option>
								<!-- <option>全部</option>
								<option>支付宝</option>
								<option>微信</option>
								<option>货到付款</option> -->
							</select>
						</div>
						<div class="layui-input-inline layui-show-xs-block flex">
							<div class="mr5">赛区</div>
							<select name="selZoneId" id="saiqu" name="zoneSelect" lay-filter="zoneSelChange">
								<option value="">请选择</option>
								<option v-for="zone in zoneList" :value="zone.zoneName">{{zone.zoneName}}</option>
								<!-- <option value="">全部</option>
								<option value="0">待确认</option>
								<option value="1">已确认</option> -->
							</select>
						</div>
						<div class="layui-input-inline layui-show-xs-block flex">
							<div class="mr5">组别</div>
							<select name="selGradeId"name="gradeSelect" id="zubie" lay-filter="gradeSelChange" >
								<option value="">请选择</option>
								<option v-for="grade in gradeList" :value="grade.gradeName">{{grade.gradeName}}</option>
								<!-- <option value="">全部</option>
								<option value="0">小学</option>
								<option value="1">初中</option>
								<option value="2">高中</option> -->
							</select>
						</div>
						<div class="layui-input-inline layui-show-xs-block flex" style=""	>
							<div class="mr5" style="width: 40px;display:none">账号</div>
							<input type="text" name="number" id="zhanghao" placeholder="账号" autocomplete="off" class="layui-input" style="display:none"></div>
						<div class="layui-input-inline layui-show-xs-block">
							<button class="layui-btn" onclick="search()">
								<i class="layui-icon">&#xe615;</i></button>
						</div>
					</form>
				</div>
				<div class="layui-card-header">
					<!--<button class="layui-btn layui-btn-danger" onclick="delAll()">-->
						<!--<i class="layui-icon"></i>批量删除-->
					<!--</button>-->
					<!--<button class="layui-btn" onclick="xadmin.open('添加用户','./order-add.html',800,600)">-->
						<!--<i class="layui-icon"></i>添加-->
					<!--</button>-->
				</div>
				<div class="layui-card-body" >
					<table class="layui-table layui-form" id="test" lay-filter="test">
						<span style="float: left;">共计{{ total }}条数据</span>
						<div class="layui-btn-container">
							<!-- <button id="referee" class="layui-btn layui-btn-sm layui-btn-disabled" onclick="selectcaipan()" style="float: right;">选择裁判</button> -->
						</div>
						<div class="layui-btn-container">
							<button class="layui-btn layui-btn-sm"  style="float: right;" onclick="donwload1()">批量下载</button>
						</div>
					</table>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
<script type="text/html" id="operating">
<a href="PreviewVideo.html?url1={{d.videoUrl}}" target="_blank" class="layui-table-link">视频</a>
</script>
<script type="text/html" id="operating1">
<a href="PreviewImg.html?url1={{d.imgUrl}}" target="_blank" class="layui-table-link">图片</a>
</script>

<script type="text/html" id="operating2">
<a href="PreviewExcel.html?url1={{d.docUrl}}" target="_blank" class="layui-table-link">预览</a>
</script>
<script src="./js/vue.js"></script>
<script>
var form
layui.use(['form', 'table'], function () {
	 form = layui.form
	// layer.msg('玩命卖萌中', function(){
	//   //关闭后的操作
	//   });
	//监听提交

	form.on('submit(search)', function (data) {
		console.log(data)
		// layer.msg(JSON.stringify(data.field), function () {
		// location.href = 'index.html'
		// })
		return false
	})


	var table = layui.table

	table.on('checkbox(test)', function(obj){ //
		console.log(obj.checked); //当前是否选中状态
		console.log(obj.data); //选中行的相关数据
		console.log(obj.type); //如果触发的是全选，则为：all，如果触发的是单选，则为：one
		console.log(table.checkStatus('test').data); // 获取表格中选中行的数据
		if (table.checkStatus('test').data.length === 0) {
			$("#referee").addClass('layui-btn-disabled')
		} else {
			$("#referee").removeClass('layui-btn-disabled')
		}

	});
})

  function selectcaipan(){
		var table = layui.table
	  var data=table.checkStatus('test').data
		// alert(JSON.stringify(data))
	  var idstring=[]
	  for (i=0;i<data.length;i++){
	 	 idstring.push(data[i].id)
	  }
		localStorage.zuopinid=idstring.toString()
		var param = {
			eq:{
				roleId:4
			}
		}

		UserinfoViewqueryList(param,function(data){
              localStorage.selectcaipanlist=JSON.stringify(data)
							xadmin.open('选择裁判','./selectReferee1.html',700,500)
		})

	}
	var app=new Vue({
		el: '#content',
		data: {
			list:[],
			aaa: 123,
			total: 0,
			zoneList:[],
			gradeList:[],
			matchList:[],
			zoneList:[],
			saichengList:[],
			status:['审核','待审核' ,'通过', '不通过'],
			participate:['审核','参赛' ,'弃权' ],
			cols: [ // 表头
				{type: 'checkbox', fixed: 'left',name:"xitong"},


				{field: 'signupId', title: '团队ID', width: 80},
				{field: 'account', title: '账号', width: 80},
				{field: 'theme', title: '赛项', width: 200},
				{field: 'scheduleName', title: '赛程'},
				{field: 'zoneName', title: '赛区'},
				{field: 'gradeName', title: '组别'},
				{field: 'teamName', title: '团队名称'},
				{field: 'memberName', title: '账号姓名'},
				// {field: 'tc', title: '指导教师',width: 100},
			  {field: 'videoUrl', title: '视频',templet: '#operating'},
				{field: 'imgUrl', title: '图片',templet: '#operating1'},
				{field: 'docUrl', title: '文档',templet: '#operating2'},

				{field: 'createTime', title: '上传时间',width: 160},
				// {field: 'operating', title: '操作', width: 135, templet: '#operating3'},
			]
		},
		methods:{
			opentab:function(name,url){
				//单击事件
				console.log(name)
				console.log(url)
				xadmin.add_tab(name,url)
			},
			loadGradeList:function(){
				GradequeryList({},function(data){
					app.gradeList=data


				},function(status,message){
				})
			},
			loadMatchList:function(){
				TmatchqueryList({},function(data){
					// alert(JSON.stringify(data))
					app.matchList=data
					// form.render("select")
				},function(status,message){
				})
			},
			loadZoneList:function(){
				var funTool = fun_tool();
				app.zoneList=funTool.getAdminZoneIds();
			},
			getsaicheng:function(){

				SchedulequeryList({},function(data){
					// alert(JSON.stringify(data))
					app.saichengList=data
					// form.render("select")
				},function(status,message){
				})
			},
			getData(){
				app.loadZoneList()
				app.loadMatchList()
				app.loadGradeList()
				app.getsaicheng()
				setTimeout(function(){
					form.render()
				},1000)
				var queryData = {
					page:{
							current:1, //当前页数
							size:10000   //每页长度
					},
					    cond:{ //条件
					        eq:{ // 多条件对象
		                    }
					    }
				};

				getMatchWorkList(queryData,function(data){
          // alert(JSON.stringify(data))
					var funTool = fun_tool();
					app.zoneList=funTool.getAdminZoneIds();
					  console.log(JSON.stringify(data))
					var teacherList=data.teacherList
					// var teacherList=[{name:"zhenxing",signupId:122}]
					//  alert(teacherList)

				  var list1=[]
					for (i=0;i<app.zoneList.length;i++){
						  list1.push(app.zoneList[i].id)
					}
					var tstring=list1.toString()
					// alert(tstring)
					var list=[]
          data=data.workList.records

					for(var i=0;i<data.length; ++i){
						  // alert(tstring.indexOf(data[i].zoneId))
							// alert(data[i].zoneId)
							// alert(tstring)
               if (tstring.indexOf(data[i].zoneId)>-1){
								 if (data[i].videoUrl==null&&data[i].imgUrl==null&&data[i].docUrl==null){

								 }
								 else{
									 list.push(data[i])
									//  list[i].index=i
									//  list[i].tc=''
									// //  alert(teacherList.length)
									//  for (j=0;j<teacherList.length;j++){
									// 	//  alert(teacherList[j].signupId)
									// 	//  alert(data[i].signupId)
									// 	    if (teacherList[j].signupId==data[i].signupId){
									// 				list[i].tc=teacherList[j].name
									// 				break
									// 			}
									//  }
								 }

							 }

					}
					app.list=list
					app.list=app.list.reverse()
				})
				this.init()
			},
			init:function() {
				var that = this
				layui.use(['laypage','table'], function () {
					// var laypage = layui.laypage;
					// //执行一个laypage实例
					// laypage.render({
					// 	elem: 'test1' //注意，这里的 test1 是 ID，不用加 # 号
					// 	,count: 16 //数据总数，从服务端得到
					// });
				 // alert(JSON.stringify(that.list))
					that.total=that.list.length
					var table = layui.table
					//头工具栏事件
					table.render({
						elem: '#test',
						url:'',
						title: '用户数据表',
						cols: [that.cols],
						page: true,
						data: that.list,
						limit:50
					})
				})
			}
		}
	})
	window.onload=function(){
		app.getData()
	}
</script>
<script src="./js/jquery.min.js"></script>
<script type="text/html" id="works">
	<a target="_blank" href="javascript:;" class="layui-table-link">下载</a>
</script>
<script type="text/html" id="operating3">
	<a href="javascript:;" onclick="xadmin.open('裁判','viewReferee.html?id='+{{d.judgeId}}+'&&name='+{{d.nickName}}+'&&workId='+{{d.id}},600,400)" class="layui-table-link">查看裁判</a>
</script>
<script>
	$(function () {


	})
	function getMatchWorkZip(query,SuccessFunc,FailedFunc) {
	    slAjax("/abkj-api-match-provider/matchExt/getMatchWorkZip?workId="+query,"get",null,SuccessFunc,FailedFunc);
	}
	function donwload1(){
		var table = layui.table
   var data=table.checkStatus('test').data
	 // alert(JSON.stringify(data))
  for (i=0;i<data.length;i++){
      // downmyfile(data[i].url)
		  // alert(data[i].id)
			getMatchWorkZip(data[i].id,function(data){
				downmyfile(data)
            // alert(JSON.stringify(data))
			})
			// downmyfile(data[i].docUrl)
			// var t1a=data[i].imgUrl
			//
			// t1a=t1a.split(',')
			// for (j=0;j<t1a.length;j++){
			// 	downmyfile(t1a[j])
			// }
	}

	}
	function downmyfile(myurl){
	    	var downloadLink = document.createElement('a');
                document.body.appendChild(downloadLink);

                // Use special ms version if available to get it working on Edge.

                downloadLink.href = myurl;
                downloadLink.target='_blank'
                // console.log(url)

                downloadLink.click();

                document.body.removeChild(downloadLink);
                window.URL.revokeObjectURL(myurl);

	}
	function search(){
		var a1=document.getElementById("saixiang").value
		var a2=document.getElementById("saiqu").value
		var a3=document.getElementById("zubie").value
		var a4=document.getElementById("zhanghao").value
		// alert(JSON.stringify(app.list))
		var list=[]
		for (i=0;i<app.list.length;i++){
			   var t1=app.list[i].theme
				 var t2=app.list[i].zoneName
				 var t3=app.list[i].gradeName
				 if (t1.indexOf(a1)>-1&&t2.indexOf(a2)>-1&&t3.indexOf(a3)>-1){
					 list.push(app.list[i])
				 }
		}
		// alert(JSON.stringify(list))

		//头工具栏事件
		layui.use(['laypage','table'], function () {
			// var laypage = layui.laypage;
			// //执行一个laypage实例
			// laypage.render({
			// 	elem: 'test1' //注意，这里的 test1 是 ID，不用加 # 号
			// 	,count: 16 //数据总数，从服务端得到
			// });
		 // alert(JSON.stringify(that.list))
			app.total=list.length
			// alert(list.length)
			var table = layui.table
			//头工具栏事件
			table.render({
				elem: '#test',
				url:'',
				title: '用户数据表',
				cols: [app.cols],
				page: true,
				data:list,
				limit:50
			})
		})

	}
</script>

</html>
